{extend name="common:base" /}

{block name="page_title"}{$controllerName}列表{/block}

{block name="content"}
<div class="box  box-primary">
    <div class="box-header with-border">
        <div class="row">
            <div class="col-xs-11">
                {if(count($whereKeys))}
                <form method="get" class="form-inline" action="{:url('index')}">
                    {volist name="whereKeys" id="v"}
                    {switch $v['type']}
                    {case text}
                    <div class="input-group">
                        <span class="input-group-addon">{$v['text']}</span>
                        <input type="text" name="search[{$v['key']}]" class="form-control" placeholder="{$v['text']}" value="{$search[$v['key']]}">
                    </div>
                    {/case}
                    {case value="select|select_empty|radio"}
                    <div class="input-group">
                        <span class="input-group-addon">{$v['text']}</span>
                        <select name="search[{$v['key']}]" class="form-control">
                            <option value="">不限</option>
                            <?php echo(getSelectHtml($v,$search[$v['key']])); ?>
                        </select>
                    </div>
                    {/case}
                    {case select_source}
                    <div class="input-group">
                        <span class="input-group-addon">{$v['text']}</span>
                        <select name="search[{$v['key']}]" class="form-control">
                            <option value="">不限</option>
                            <?php echo(getSelectHtml($v,$search[$v['key']],$selectList[$v['type_value_custom']['source']])); ?>
                        </select>
                    </div>
                    {/case}
                    {/switch}
                    {/volist}
                    <div class="btn-group">
                        <button type="submit" class="btn btn-primary">搜索</button>
                        <a class="btn btn-success" href="{:url('index')}">全部</a>
                    </div>
                </form>
                {/if}
            </div>
            <div class="col-xs-1">
                <div class="btn-group">
                    <a href="{:url('add')}" class="btn btn-default">添加</a>
                    <!--
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                        <span class="sr-only">Toggle Dropdown</span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                    </ul>
                    -->
                </div>
            </div>
        </div>
    </div>
    <div class="box-body">
        <table class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                {volist name="listFields" id="f"}
                <th>{$f['text']}</th>
                {/volist}
                <th style="width: 120px">操作</th>
            </tr>
            </thead>
            <tbody>
            {if(count($datas) > 0)}
            {volist name="datas" id="v"}
            <tr>
                {volist name="listFields" id="f"}
                <td>
                    {:getListSelectValue($f,$v,$selectList)}
                </td>
                {/volist}
                <td>
                    {volist name="operationBtns" id="ob"}
                    {switch $ob['type']}
                    {case btn}
                    <a href="{$ob['href']}?{$ob['var']}={$v[$ob['var']]}">{$ob['text']}</a>
                    {/case}
                    {case confirm-rst-url-btn}
                    <a class="confirm-rst-url-btn" href="{$ob['href']}?{$ob['var']}={$v[$ob['var']]}" data-info="{$ob['tip']}">{$ob['text']}</a>
                    {/case}
                    {/switch}
                    {/volist}
                    <a href="{:url('edit',array('id'=>hashIdEncode($v['id'])))}">编辑</a>
                    <a class="confirm-rst-url-btn" href="{:url('del',array('id'=>hashIdEncode($v['id'])))}" data-info="你确定要删除吗？">删除</a>
                </td>
            </tr>
            {/volist}
            {else /}
            <tr>
                <td colspan="99" style="text-align:center;">暂无数据</td>
            </tr>
            {/if}
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <div id="page1" class="pull-right"></div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    var totalPages = {$totalPages};
    var pageIndex = {$pageIndex};
    var currSize = {:count($datas)};
    var totalRows = {$totalRows};
    laypage({
        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
        pages: totalPages, //通过后台拿到的总页数
        curr: pageIndex, //当前页
        currSize:currSize,
        totalRows:totalRows,
        skip: true, //是否开启跳页
        jump: function(obj, first){ //触发分页后的回调
            if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                location.href = "{$pageUrl|raw}" +  "&p=" + obj.curr
            }
        }
    });
</script>
{/block}